<?php 

$user = $this->lock->getAdminUserRowByAdminUserId();
$userName = $user->getName() ? $user->getName() : $user->getLogin();

$created = strtotime($this->lock->getCreated());
$countdown = strtotime("+15 min", $created);

?>
     <script type="text/javascript">
        time_diff = <?php echo ($countdown - time()); ?>;
  
        function countDown() {      
           work_number = time_diff--;
           days = Math.floor(work_number / 86400);      
           work_number -= days * 86400;
           hours = Math.floor(work_number / 3600);
           work_number -= hours * 3600;
           minutes = Math.floor(work_number / 60);
           work_number -= minutes * 60;
           seconds = Math.floor(work_number % 60);
           days = (days < 10) ? "0"+days : days;
           hours = (hours < 10) ? "0"+hours : hours;
           minutes = (minutes < 10) ? "0"+minutes : minutes;
           seconds = (seconds < 10) ? "0"+seconds : seconds;
           values = [
              //declOfNum(days, ["день", "дня", "дней"]), 
              //declOfNum(hours, ["час", "часа", "часов"]), 
              declOfNum(minutes, ["минута", "минуты", "минут"]), 
              declOfNum(seconds, ["секунда", "секунды", "секунд"])
           ];
           document.getElementById('counter').innerHTML =  values.join(" ") + ".";      
        }

        function declOfNum(number, titles) {
           cases = [2, 0, 1, 1, 1, 2];
           return "<b>" + number + "</b> " + titles[ (number%100>4 && number%100<20)? 2 : cases[Math.min(number%10, 5)] ];
        }

        setInterval("countDown()", 1000);
     </script>


<div align="left">
	<div align="right" style="width:80%">
		<h3>Данная запись уже редактируется пользователем <?php echo $userName; ?></h3><br/>
		<p>Время до истечения блокировки: <span id="counter">...</span></p>
		<p><a href="#" onClick="history.back();return false;">Назад</a></p>
		<p><a href="<?php 
		        echo $this->url(array('module' => 'admin', 'controller' => 'crud', 'action' => 'index'), null, true);
		    ?>">На главную
		</a></p>
	</div>
</div>